﻿using System;
using System.Collections.Generic;
using System.Linq;


class MaximalSumOfArray
{
    static void Main()
    {
        try
        {
            List<int> array = new List<int> {2, 3, -6, -1, 2, -1, 6, 4, -8, 8};
            int size = array.Count;
            List<int> elements = new List<int>();
            int maxSum = 0;
            int copymaxSum = 0;
            int copyvalue = 0;           

            for (int i = 0; i < size; i++)
            {
                copyvalue = array[i];
             

                for (int j = i; j < size; j++)
                {
                    copyvalue += array[j];
                    if (j == i)
                    {
                        copyvalue -= array[j];
                    }
                    if (copyvalue > maxSum)
                    {
                        elements.Clear();
                        int k = j;
                        maxSum = copyvalue;
                        copymaxSum = maxSum;
                        
                        while (copymaxSum != 0)
                        {                            
                            copymaxSum -= array[k];
                            elements.Add(array[k]);
                            k--;
                        }
                    }                   
                    
                }
                
            }
            for (int i = elements.Count - 1; i >= 0; i--)
            {
                Console.Write(" " + elements[i]);
            }
            Console.WriteLine();
        }
        catch (Exception)
        {
            Console.WriteLine("Wrong data!");
            return;
        }
    }
}